/**
 * ListAction.java 2008-05-19
 * 
 * Linker is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 *
 */

package linker.list;

import javax.swing.JPopupMenu;

/**
 * ListAction handles list action such as double click and don't need to know
 * the current list.
 * 
 * @version 2008-5-20
 * @author Tan tan1986@gmail.com
 * 
 */

public class ListAction {

	/**
	 * The current state.
	 */
	private ListState state;

	/**
	 * @param listState
	 *            The default listState.
	 */
	public ListAction(final ListState listState) {

		// default state
		this.state = listState;
	}

	/**
	 * The the current state by its type.
	 * 
	 * @param listState
	 *            The new state type.
	 */
	public final void setState(final ListState listState) {
		this.state = listState;
	}

	/**
	 * Get double click funtion by the selected list item.
	 * 
	 * @param item
	 *            The selected list item.
	 */
	public final void doubleClick(final ListItem item) {
		state.doubleClickByItem(item);
	}

	/**
	 * Get popupMenu.
	 * 
	 * @param listItem
	 *            The selected list item.
	 * 
	 * @return The PopupMenu.
	 */
	public final JPopupMenu getPopupMenu(final ListItem listItem) {
		return state.getPopupMenuByItem(listItem);
	}

	/**
	 * 
	 */
	public static enum TYPE {
		/**
		 * The 3 types of list.
		 */
		PLUGINLIST, MESSAGELIST, BUDDYLIST
	}
}
